/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.vacuela.publish.desktop;

import com.u2d.model.AbstractComplexEObject;
import com.u2d.model.Title;
import com.u2d.type.atom.StringEO;
import com.u2d.list.RelationalList;
import com.u2d.app.User;
import static com.u2d.pubsub.AppEventType.*;
import java.awt.Color;


/**
 *
 * @author Prueba
 */

public class MyGroup  extends AbstractComplexEObject {
 private User _createdBy;
 private final StringEO _title = new StringEO();
 private final StringEO _groupName = new StringEO();
 //public static String[] readOnly = {"createdBy"};
 
 
 
  private final RelationalList _contacts = new RelationalList(Contact.class);
  public static Class contactsType = Contact.class;
  public static String contactsInverseFieldName = "mygroup";
  
   public static Color colorCode = new Color(0x8470FF);
   public static String[] fieldOrder =   {"groupName", "createdBy","contacts"};  
   public static String[] identities = {"groupName","createdBy"};
   public static String[] hidden = {"createdBy"};
   
   

   public MyGroup() {}
 public void onBeforeCreate()
   {
      super.onBeforeCreate();
      setCreatedBy(currentUser());
   }

 public User getCreatedBy() { return _createdBy; }
   public void setCreatedBy(User user)
   {
      User oldValue = _createdBy;
      _createdBy = user;
      firePropertyChange("createdBy", oldValue, _createdBy);
   }

     public Title title()
   {
      return _title.title().append(_groupName);
   }


    public StringEO getGroupName(){
        return _groupName;
    }
    public static String typeFilter() {
        return "createdBy_id = :currentUser"; }
    
    public RelationalList getContacts() { return _contacts; }
}
